/*
 * Copyright (c) 2010-2020 IISI.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of IISI.
 */
package com.iisigroup.log.analysis.model;

import java.io.Serializable;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 */
public class StuckThreadRecord implements Serializable {

    //================================================
    //== [Enumeration types] Block Start
    //== [Enumeration types] Block End 
    //================================================
    //== [static variables] Block Start
    /**  */
    private static final long serialVersionUID = -3148758917074778684L;
    //== [static variables] Block Stop 
    //================================================
    //== [instance variables] Block Start
    private InfoUnit originalData;

    private String hostIp;

    private String clientIp;

    private String userId;

    private String date;

    private String time;

    private String originalFilePath;
    
    private final static String stackTraceRegExpr= "(\\w*\\.[\\w|\\.|\\$]*\\(.*\\))" ;

    public InfoUnit getOriginalData() {
        return this.originalData;
    }

    public void setOriginalData(InfoUnit originalData) {
        this.originalData = originalData;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getDate() {
        return this.date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTime() {
        return this.time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getClientIp() {
        return this.clientIp;
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public String getHostIp() {
        return this.hostIp;
    }

    public void setHostIp(String hostIp) {
        this.hostIp = hostIp;
    }

    public String getOriginalFilePath() {
        return this.originalFilePath;
    }

    public void setOriginalFilePath(String originalFilePath) {
        this.originalFilePath = originalFilePath;
    }

    //== [instance variables] Block Stop 
    //================================================
    //== [static Constructor] Block Start
    //== [static Constructor] Block Stop 
    //================================================
    //== [Constructors] Block Start (含init method)
    //== [Constructors] Block Stop 
    //================================================
    //== [Static Method] Block Start
    //== [Static Method] Block Stop 
    //================================================
    //== [Accessor] Block Start
    //== [Accessor] Block Stop 
    //================================================
    //== [Overrided Method] Block Start (Ex. toString/equals+hashCode)
    public String getStackTrace(){
        String result =null;
        if (this.originalData != null) {           
           final List<String> lines = this.originalData .getOriginalData();
           final StringBuilder sbf = new StringBuilder();
           final Pattern pattern = Pattern.compile(stackTraceRegExpr);
           for(final String line : lines){
               final Matcher matcher = pattern.matcher(line);
               while(matcher.find()){
                 String tmp =   matcher.group(matcher.groupCount());
                 sbf.append(tmp).append("\r\n");                 
               }
           }
           result= sbf.toString().intern();
        }
        return result ;
    }

    //== [Overrided Method] Block Stop 
    //================================================
    //== [Method] Block Start    
    //####################################################################

    //## [Method] sub-block : 
    //####################################################################    
    //== [Method] Block Stop 
    //================================================
    //== [Inner Class] Block Start
    //== [Inner Class] Block Stop 
    //================================================
}
